import {messages} from "share/common";
import React from 'react';
import {Popover, Badge, Popconfirm} from 'antd'

export default {

  getNewOpenConsumerColumns(supplier, context) {
    const {onDeleteRecord, GoToSettingDetail} = context;
    switch(supplier) {
      case 'yget':
        return [
          {
            title: messages('supplier-1.key32')/*公司编码*/,
            dataIndex: 'companyCode',
            key: 'companyCode',
            render: value => (
              <Popover placement="topLeft" content={value}>
                <span>{value}</span>
              </Popover>
            )
          },
          {
            title: messages('supplier-1.key33')/*公司名称*/,
            dataIndex: 'companyName',
            key: 'companyName',
            render: value => (
              <Popover placement="topLeft" content={value}>
                <span>{value}</span>
              </Popover>
            )
          },
          {
            title: messages('common.column.status')/*状态*/,
            dataIndex: 'enable',
            key: 'enable',
            render: value => {
              value = value + '';
              switch (value){
                case 'false': return <Badge status="error" text={messages('supplier-1.key34')/*禁用temp*/} />;
                case 'true': return <Badge status="success" text={messages('supplier-1.key35')/*启用temp*/} />;
              }
            }
          },
          {
            title: messages('common.operation')/*操作*/,
            dataIndex:'operator',
            key:'operator',
            render:() => <a>{messages('common.edit')/*编辑*/}</a>
          },
        ]
      case 'zhenxuanair':
      case 'heliosHotel':
        return [
          {
            title: messages('supplier-1.key36')/*层级*/,
            dataIndex: 'levelCode',
            key: 'levelCode',
            render: (value) => {
              switch (value){
                case 'COMPANY':
                  return messages('supplier-1.key37')/*公司*/;
                case 'TENANT':
                  return messages('supplier-1.key38')/*租户*/;
              }
            }
          },
          {
            title: messages('supplier-1.key39')/*所属组织*/,
            dataIndex: 'tenantName',
            key: 'tenantName',
          },
          {
            title: messages('supplier-1.key40')/*应用公司*/,
            dataIndex: 'distLevelOrgName',
            key: 'distLevelOrgName',
            render: value => <Popover placement="topLeft" content={value}>{value}</Popover>
          },
          {
            title: messages('supplier-1.key41')/*说明*/,
            dataIndex: 'vendorKey',
            key: 'vendorKey',
            render: value => (
              <Popover placement="topLeft" content={value}>
                <span>{value}</span>
              </Popover>
            )
          },
          {
            title: messages('common.column.status')/*状态*/,
            dataIndex: 'corpStatus',
            key: 'corpStatus',
            render: value => {
              switch (value){
                case 0: return <Badge status="default" text={messages('supplier-1.key42')/*未配置*/} />;
                case 'INVALID': return <Badge status="error" text={messages('supplier-1.key34')/*禁用temp*/} />;
                case 'NORMAL': return <Badge status="success" text={messages('supplier-1.key35')/*启用temp*/} />;
                default: return <Badge status="default" text={messages('supplier-1.key42')/*未配置*/} />;
              }
            }
          },
          {
            title: messages('common.operation')/*操作*/,
            dataIndex:'operator',
            key:'operator',
            render:(value, record) => {
              return (
                <div>
                  <a onClick={(e) => {e.stopPropagation();GoToSettingDetail(record)}}>{messages('common.detail')/*详情*/}</a>
                  &nbsp;
                  <a>{messages('common.edit')/*编辑*/}</a>
                  &nbsp;
                  <Popconfirm
                    placement="topLeft"
                    title={messages('supplier-1.key43')/*确认删除*/ + '?'}
                    onConfirm={(e)=>onDeleteRecord(record,e)}
                    okText={messages('common.ok')/*确定*/}
                    cancelText={messages('common.cancel')/*取消*/}
                  >
                    <a style={{color: 'red'}} onClick={(e) => {e.stopPropagation();}}>{messages('common.delete')/*删除*/}</a>
                  </Popconfirm>
                </div>
              )
            }
          },
        ];
      case 'meiya':
        return [
          {
            title: messages('supplier-1.key36')/*层级*/,
            dataIndex: 'levelCode',
            key: 'levelCode',
            render: (value) => {
              switch (value){
                case 'COMPANY':
                  return messages('supplier-1.key37')/*公司*/;
                case 'TENANT':
                  return messages('supplier-1.key38')/*租户*/;
              }
            }
          },
          {
            title: messages('supplier-1.key39')/*所属组织*/,
            dataIndex: 'tenantName',
            key: 'tenantName',
          },
          {
            title: messages('supplier-1.key40')/*应用公司*/,
            dataIndex: 'distLevelOrgName',
            key: 'distLevelOrgName',
            render: value => <Popover placement="topLeft" content={value}>{value}</Popover>
          },
          {
            title: messages('supplier-1.key44')/*美亚公司ID*/,
            dataIndex: 'vendorCompanyId',
            key: 'vendorCompanyId'
          },
          {
            title: messages('supplier-1.key45')/*渠道号*/,
            dataIndex: 'channel',
            key: 'channel'
          },
          {
            title: messages('supplier-1.key46')/*H5 Key*/,
            dataIndex: 'vendorH5Key',
            key: 'vendorH5Key',
            render: value => (
              <Popover placement="topLeft" content={value}>
                <span>{value}</span>
              </Popover>
            )
          },
          {
            title: 'Web Key',
            dataIndex: 'vendorKey',
            key: 'vendorKey',
            render: value => (
              <Popover placement="topLeft" content={value}>
                <span>{value}</span>
              </Popover>
            )
          },
          {
            title: messages('common.column.status')/*状态*/,
            dataIndex: 'corpStatus',
            key: 'corpStatus',
            render: value => {
              switch (value){
                case 0: return <Badge status="default" text={messages('supplier-1.key42')/*未配置*/} />;
                case 'INVALID': return <Badge status="error" text={messages('supplier-1.key34')/*禁用temp*/} />;
                case 'NORMAL': return <Badge status="success" text={messages('supplier-1.key35')/*启用temp*/} />;
                default: return <Badge status="default" text={messages('supplier-1.key42')/*未配置*/} />;
              }
            }
          },
          {
            title: messages('common.operation')/*操作*/,
            dataIndex:'operator',
            key:'operator',
            render:(value, record) => {
              return (
                <div>
                  <a>{messages('common.edit')/*编辑*/}</a>
                  &nbsp;
                  <Popconfirm
                    placement="topLeft"
                    title={messages('supplier-1.key43')/*确认删除*/ + '?'}
                    onConfirm={(e)=>onDeleteRecord(record,e)}
                    okText={messages('common.ok')/*确定*/}
                    cancelText={messages('common.cancel')/*取消*/}
                  >
                    <a style={{color: 'red'}} onClick={(e) => {e.stopPropagation();}}>{messages('common.delete')/*删除*/}</a>
                  </Popconfirm>
                </div>
              )
            }
          },
        ];
      case 'ctrip':
        return [
          {
            title: messages('supplier-1.key36')/*层级*/,
            dataIndex: 'levelCode',
            key: 'levelCode',
            render: (value) => {
              switch (value){
                case 'COMPANY':
                  return messages('supplier-1.key37')/*公司*/;
                case 'TENANT':
                  return messages('supplier-1.key38')/*租户*/;
              }
            }
          },
          {
            title: messages('supplier-1.key39')/*所属组织*/,
            dataIndex: 'tenantName',
            key: 'tenantName',
          },
          {
            title: messages('supplier-1.key40')/*应用公司*/,
            dataIndex: 'distLevelOrgName',
            key: 'distLevelOrgName',
            render: value => <Popover placement="topLeft" content={value}>{value}</Popover>
          },
          {
            title: messages('supplier-1.key47')/*携程账户类型*/,
            dataIndex: 'isBigCus',
            key: 'isBigCus',
            render: value => {
              if(value){
                return messages('supplier-1.key48')/*携程大客户*/;
              }else{
                return messages('supplier-1.key49')/*携程小客户*/;
              }
            }
          },
          {
            title: 'App Key',
            dataIndex: 'appKey',
            key: 'appKey'
          },
          {
            title: 'App Secret',
            dataIndex: 'appSecurity',
            key: 'appSecurity'
          },
          {
            title: 'Account ID',
            dataIndex: 'accountID',
            key: 'accountID'
          },
          {
            title: messages('common.column.status')/*状态*/,
            dataIndex: 'enabled',
            key: 'enabled',
            render: value => {
                if(value){
                  return <Badge status="success" text={messages('supplier-1.key35')/*启用temp*/} />;
                }else{
                  return <Badge status="error" text={messages('supplier-1.key34')/*禁用temp*/} />;
                }
            }
          },
          {
            title: messages('common.operation')/*操作*/,
            dataIndex:'operator',
            key:'operator',
            render:(value, record) => {
              return (
                <div>
                  <a>{messages('common.edit')/*编辑*/}</a>
                  &nbsp;
                  <Popconfirm
                    placement="topLeft"
                    title={messages('supplier-1.key43')/*确认删除*/ + '?'}
                    onConfirm={(e)=>onDeleteRecord(record,e)}
                    okText={messages('common.ok')/*确定*/}
                    cancelText={messages('common.cancel')/*取消*/}
                  >
                    <a style={{color: 'red'}} onClick={(e) => {e.stopPropagation();}}>{messages('common.delete')/*删除*/}</a>
                  </Popconfirm>
                </div>
              )
            }
          }
        ];
      case 'didi':
        return [
          {
            title: messages('supplier-1.key36')/*层级*/,
            dataIndex: 'levelCode',
            key: 'levelCode',
            render: (value) => {
              switch (value){
                case 'COMPANY':
                  return messages('supplier-1.key37')/*公司*/;
                case 'TENANT':
                  return messages('supplier-1.key38')/*租户*/;
              }
            }
          },
          {
            title: messages('supplier-1.key39')/*所属组织*/,
            dataIndex: 'tenantName',
            key: 'tenantName',
          },
          {
            title: messages('supplier-1.key40')/*应用公司*/,
            dataIndex: 'distLevelOrgName',
            key: 'distLevelOrgName',
            render: value => <Popover placement="topLeft" content={value}>{value}</Popover>
          },
          {
            title: messages('supplier-1.key50')/*滴滴company ID*/,
            dataIndex: 'didiCompanyId',
            key: 'didiCompanyId'
          },
          {
            title: messages('common.column.status')/*状态*/,
            dataIndex: 'enabled',
            key: 'enabled',
            render:  value => {
              if(value){
                return <Badge status="success" text={messages('supplier-1.key35')/*启用temp*/} />;
              }else{
                return <Badge status="error" text={messages('supplier-1.key34')/*禁用temp*/} />;
              }
            }
          },
          {
            title: messages('common.operation')/*操作*/,
            dataIndex:'operator',
            key:'operator',
            render:(value, record) => {
              return (
                <div>
                  <a>{messages('common.edit')/*编辑*/}</a>
                  &nbsp;
                  <Popconfirm
                    placement="topLeft"
                    title={messages('supplier-1.key43')/*确认删除*/ + '?'}
                    onConfirm={(e)=>onDeleteRecord(record,e)}
                    okText={messages('common.ok')/*确定*/}
                    cancelText={messages('common.cancel')/*取消*/}
                  >
                    <a style={{color: 'red'}} onClick={(e) => {e.stopPropagation();}}>{messages('common.delete')/*删除*/}</a>
                  </Popconfirm>
                </div>
              )
            }
          }
        ];
      case 'travelnoone':return [
        {
          title: messages('supplier-1.key36')/*层级*/,
          dataIndex: 'levelCode',
          key: 'levelCode',
          render: (value) => {
            switch (value){
              case 'COMPANY':
                return messages('supplier-1.key37')/*公司*/;
              case 'TENANT':
                return messages('supplier-1.key38')/*租户*/;
            }
          }
        },
        {
          title: messages('supplier-1.key39')/*所属组织*/,
          dataIndex: 'tenantName',
          key: 'tenantName',
        },
        {
          title: messages('supplier-1.key40')/*应用公司*/,
          dataIndex: 'distLevelOrgName',
          key: 'distLevelOrgName',
          render: value => <Popover placement="topLeft" content={value}>{value}</Popover>
        },
        {
          title: messages('common.column.status')/*状态*/,
          dataIndex: 'enabled',
          key: 'enabled',
          render: value => {
              if(value){
                return <Badge status="success" text={messages('supplier-1.key35')/*启用temp*/} />;
              }else{
                return <Badge status="error" text={messages('supplier-1.key34')/*禁用temp*/} />;
              }
          }
        },
        {
          title: messages('common.operation')/*操作*/,
          dataIndex:'operator',
          key:'operator',
          render:(value, record) => {
            return (
              <div>
                <a>{messages('common.edit')/*编辑*/}</a>
                &nbsp;
                <Popconfirm
                  placement="topLeft"
                  title={messages('supplier-1.key43')/*确认删除*/ + '?'}
                  onConfirm={(e)=>onDeleteRecord(record,e)}
                  okText={messages('common.ok')/*确定*/}
                  cancelText={messages('common.cancel')/*取消*/}
                >
                  <a style={{color: 'red'}} onClick={(e) => {e.stopPropagation();}}>{messages('common.delete')/*删除*/}</a>
                </Popconfirm>
              </div>
            )
          }
        },
      ];
      default:
        return []
    }
  },

  getOtherTravelColumns(context){
    const {onEditButton, onDeleteButton} = context;
    return [
      {
        title: messages('supplier-1.key36')/*层级*/,
        key: 'levelCode',
        dataIndex: 'levelCode',
        render: (value) => {
          switch (value){
            case 'COMPANY':
              return messages('supplier-1.key37')/*公司*/;
            case 'TENANT':
              return messages('supplier-1.key38')/*租户*/;
          }
        }
      },
      {
        title: messages('supplier-1.key39')/*所属组织*/,
        key: 'tenantName',
        dataIndex: 'tenantName',
      },
      {
        title: messages('supplier-1.key40')/*应用公司*/,
        key: 'distLevelOrgName',
        dataIndex: 'distLevelOrgName',
      },
      {
        title: messages('supplier-1.key51')/*行程类型*/,
        key: 'tripType',
        dataIndex: 'tripType',
      },
      {
        title: messages('common.operation')/*操作*/,
        dataIndex:'operator',
        key:'operator',
        render:(value, record) => {
          return (
            <div>
              <a onClick={()=> onEditButton(record)}>{messages('common.edit')/*编辑*/}</a>
              &nbsp;
              <Popconfirm
                placement="topLeft"
                title={messages('supplier-1.key43')/*确认删除*/ + '?'}
                onConfirm={(e)=>onDeleteButton(record,e)}
                okText={messages('common.ok')/*确定*/}
                cancelText={messages('common.cancel')/*取消*/}
              >
                <a style={{color: 'red'}} onClick={(e) => {e.stopPropagation();}}>{messages('common.delete')/*删除*/}</a>
              </Popconfirm>
            </div>
          )
        }
      }
    ]
  }
}
